home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / Utilities / Pictoids / Picture MDEF ƒ / menu demo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-04  |  1.4 KB  |  56 lines  |  [TEXT/KAHL]

  1. /* A VERY simple demo of the Picture MDEF for programmers.
  2.  
  3.    Picture MDEF © Nigel Perry, 1990-1
  4.    
  5.    Free for personal use and in stacks & applications which are free.
  6.    May not be used for commercial or profit-making purposes or in
  7.    ShareWare without permission.
  8.    
  9.    Nigel Perry (np@doc.ic.ac.uk), Dec 90 & Apr 91.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <asm.h>
  14. #include "PicMDEF.h"
  15.  
  16. main()
  17. {    MenuHandle mh;
  18.     PicHandle ph;
  19.     nrctHand nh;
  20.     EventRecord event;
  21.     WindowPtr wp;
  22.     union { long l; Point pt; } hit;
  23.  
  24.     printf("Picture MDEF Programmers Demo\nSelect Quit to finish\n\n");
  25.     
  26.     /* get resources */
  27.     ph = (PicHandle)GetNamedResource('PICT', "\pDemo");
  28.     nh = (nrctHand)GetNamedResource('nrct', "\pDemo");
  29.     /* get menu */
  30.     mh = NewPicMenu((StringPtr)"\pPicture", ph, nh);
  31.     /* stuff in menu bar */
  32.     InsertMenu(mh, 0);
  33.     DrawMenuBar();
  34.     
  35.     /* loop and print menu/item */
  36.     while(1)
  37.     {    if( GetNextEvent(-1, &event)/* && !StdEvent(&event)*/ )
  38.         {    if( FindWindow(event.where, &wp) == inMenuBar )
  39.             {    hit.l = MenuSelect(event.where);
  40.                 printf("Menu: %d Item: %d\n", hit.pt.v, hit.pt.h);
  41.                 /* tear off? */
  42.                 if(hit.pt.h == -1)
  43.                     printf("Palette Loc (%d,%d)\n",
  44.                         (*(PicMenuHandle)mh)->tearLoc.v,
  45.                         (*(PicMenuHandle)mh)->tearLoc.h);
  46.                 /* Quit item, this is a SIMPLE demo! */
  47.                 if(hit.l == 0x20001) break;
  48.                 HiliteMenu(0);
  49.             }
  50.         }
  51.     }
  52.     
  53.     ReleaseResource(ph);
  54.     ReleaseResource(nh);
  55.     DisposePicMenu(mh);
  56. }